import sqlite3

# 连接数据库
conn = sqlite3.connect('../instance/dev.db')
cursor = conn.cursor()

# 获取所有表
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = cursor.fetchall()
print("数据库中的表:")
for table in tables:
    print(f"- {table[0]}")

# 检查users表结构
if ('users',) in tables:
    cursor.execute("PRAGMA table_info(users);")
    columns = cursor.fetchall()
    print("\nusers表结构:")
    for col in columns:
        print(f"- {col[1]} ({col[2]})")

# 查看users表中的数据
cursor.execute("SELECT * FROM users;")
users = cursor.fetchall()
print(f"\nusers表中的数据 (共{len(users)}条):")
for user in users:
    print(user)

# 关闭连接
conn.close()